<!doctype html>
<html class="no-js">
<head>
    <title>ZTE 中兴金融科技</title>
    {{include 'base/style.html'}}
    <link rel="stylesheet" href="{{=URL('static','module/login/css/app.css')}}">
</head>
<style>
</style>
<body data-type="login" style="background: #334054;">
<button id="close" type="button" class=" am-close am-close-spin">&times;</button>
<div class="am-g myapp-login" >
	<div class="myapp-login-bg">


            <div class="myapp-login-logo-text">
                找回密码
            </div>
	            <form id="form" action="" class="am-form">
					<fieldset>
						<div class="am-form-group">
						<label for="username">手机号</label>
						<input type="text" id="username" minlength="11" maxlength="11" placeholder="请输入手机号" class="am-form-field" required/>
						</div>
						<div class="am-form-group myapp-login-treaty"><label class="am-form-label"></label><label class="am-checkbox-inline">请填入注册手机号以接收验证码</label></div>
						<button class="myapp-login-button am-btn am-btn-secondary" type="button" id="next_btn">下一步</button>
					</fieldset>

				</form>




	</div>
</div>


<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
  <div class="am-modal-dialog">
    <div class="am-modal-hd">该手机号尚未注册</div>
      <div class="am-modal-bd"></div>
    <div class="am-modal-footer">
      <span class="am-modal-btn">确定</span>
    </div>
  </div>
</div>

{{include 'base/jsFile.html'}}
<script>
    var temp="{{=request.vars.type}}";
    var url= "{{=URL('finance','mind')}}";
    if(temp==1){
       url= "{{=URL('finance','myassets')}}";
    }
    $('#close').click(function () {
        window.location.href =url;
    })


	    $('#next_btn').click(function () {
       var username= document.getElementById("username");
       if(username.value==""){
            username.setCustomValidity("手机号不能为空");
       }else{
            var re = /^1\d{10}$/
            if (re.test(username.value)) {
                username.setCustomValidity("");
            } else {
                username.setCustomValidity("手机格式不正确");
            }
       }


        if(document.getElementById("form").checkValidity()){
            $.ajax({//http://10.204.127.36:8000/appweb/v1/test/1.json
                //url:"{{=URL('v1','test')}}/1.json",
                url:"{{=URL('v1','findpw')}}/"+username.value,
                type: "GET",
                headers:{
                    "cube_user_token":"123token",
                    "Content-Type":"application/json"
                },
                contentType: 'text/html; charset=UTF-8',
                dataType: "json",
                success: function(data) {
//                   alert(JSON.stringify(data)); // Object
                    if(data.user!=""){
                         window.location.href ="{{=URL('finance','findpdcon')}}?type={{=request.vars.type}}&username="+username.value
                    }else{
                        $('#my-alert').modal();
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
        //            alert(XMLHttpRequest.status);
        //            alert(XMLHttpRequest.readyState);
                    alert(errorThrown);
                },
                complete: function(XMLHttpRequest, textStatus) {
                }

            });

        }



    })



</script>
</body>
</html>